<template>
  <div class="route-test">
    <div class="test-header">
      <h1>压力热图路由测试</h1>
      <p>测试所有压力热图相关的路由配置</p>
    </div>
    
    <div class="test-content">
      <div class="route-section">
        <h2>主要路由</h2>
        <div class="route-list">
          <div class="route-item">
            <router-link to="/pressure-heatmap" class="route-link">
              /pressure-heatmap
            </router-link>
            <span class="route-desc">独立压力热图页面</span>
          </div>
          
          <div class="route-item">
            <router-link to="/data-monitoring" class="route-link">
              /data-monitoring
            </router-link>
            <span class="route-desc">数据监控主页面（重定向到压力热图）</span>
          </div>
        </div>
      </div>
      
      <div class="route-section">
        <h2>数据监控子路由</h2>
        <div class="route-list">
          <div class="route-item">
            <router-link to="/data-monitoring/realtime" class="route-link">
              /data-monitoring/realtime
            </router-link>
            <span class="route-desc">实时数据监控</span>
          </div>
          
          <div class="route-item">
            <router-link to="/data-monitoring/history" class="route-link">
              /data-monitoring/history
            </router-link>
            <span class="route-desc">历史数据分析</span>
          </div>
          
          <div class="route-item">
            <router-link to="/data-monitoring/trend" class="route-link">
              /data-monitoring/trend
            </router-link>
            <span class="route-desc">趋势分析</span>
          </div>
          
          <div class="route-item">
            <router-link to="/data-monitoring/pressure-heatmap" class="route-link">
              /data-monitoring/pressure-heatmap
            </router-link>
            <span class="route-desc">压力热图（默认页面）</span>
          </div>
        </div>
      </div>
      
      <div class="route-section">
        <h2>带参数的路由测试</h2>
        <div class="route-list">
          <div class="route-item">
            <button @click="navigateWithParams" class="route-button">
              测试带查询参数的路由
            </button>
            <span class="route-desc">area=A&view=2D&showGrid=true</span>
          </div>
          
          <div class="route-item">
            <button @click="navigateWithTimeRange" class="route-button">
              测试时间范围参数
            </button>
            <span class="route-desc">startTime & endTime 参数</span>
          </div>
        </div>
      </div>
      
      <div class="route-section">
        <h2>编程式导航测试</h2>
        <div class="route-list">
          <div class="route-item">
            <button @click="navigateByName" class="route-button">
              通过路由名称导航
            </button>
            <span class="route-desc">使用 router.push({ name: 'xxx' })</span>
          </div>
          
          <div class="route-item">
            <button @click="navigateBack" class="route-button">
              返回上一页
            </button>
            <span class="route-desc">使用 router.back()</span>
          </div>
        </div>
      </div>
    </div>
    
    <div class="current-route">
      <h3>当前路由信息</h3>
      <div class="route-info">
        <div class="info-item">
          <strong>路径:</strong> {{ $route.path }}
        </div>
        <div class="info-item">
          <strong>名称:</strong> {{ $route.name }}
        </div>
        <div class="info-item">
          <strong>查询参数:</strong> {{ JSON.stringify($route.query) }}
        </div>
        <div class="info-item">
          <strong>元信息:</strong> {{ JSON.stringify($route.meta) }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PressureHeatmapRouteTest',
  methods: {
    navigateWithParams() {
      this.$router.push({
        path: '/data-monitoring/pressure-heatmap',
        query: {
          area: 'A',
          view: '2D',
          showGrid: 'true',
          showValues: 'true'
        }
      })
    },
    
    navigateWithTimeRange() {
      this.$router.push({
        path: '/data-monitoring/pressure-heatmap',
        query: {
          startTime: '2023-11-28 00:00:00',
          endTime: '2023-11-28 23:59:59',
          area: 'B'
        }
      })
    },
    
    navigateByName() {
      this.$router.push({
        name: 'DataMonitoringRealtime'
      })
    },
    
    navigateBack() {
      this.$router.back()
    }
  }
}
</script>

<style scoped>
.route-test {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  font-family: 'Inter', sans-serif;
}

.test-header {
  text-align: center;
  margin-bottom: 40px;
}

.test-header h1 {
  color: #1677FF;
  font-size: 32px;
  margin-bottom: 10px;
}

.test-header p {
  color: #6B7280;
  font-size: 16px;
}

.test-content {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.route-section {
  background: #FFFFFF;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.route-section h2 {
  color: #000000;
  font-size: 20px;
  margin-bottom: 16px;
  border-bottom: 2px solid #1677FF;
  padding-bottom: 8px;
}

.route-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.route-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: #F9FAFB;
  border-radius: 6px;
  border-left: 4px solid #E5E7EB;
  transition: all 0.2s;
}

.route-item:hover {
  border-left-color: #1677FF;
  background: #F0F9FF;
}

.route-link {
  background: #1677FF;
  color: #FFFFFF;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 14px;
  transition: all 0.2s;
  min-width: 300px;
  text-align: center;
}

.route-link:hover {
  background: #0958d9;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 119, 255, 0.3);
}

.route-link.router-link-active {
  background: #52C41A;
}

.route-button {
  background: #FAAD14;
  color: #FFFFFF;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 300px;
}

.route-button:hover {
  background: #D48806;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(250, 173, 20, 0.3);
}

.route-desc {
  color: #6B7280;
  font-size: 14px;
  flex: 1;
}

.current-route {
  background: #F3F4F6;
  border-radius: 8px;
  padding: 20px;
  margin-top: 30px;
}

.current-route h3 {
  color: #000000;
  font-size: 18px;
  margin-bottom: 16px;
}

.route-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-item {
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 14px;
  color: #4B5563;
  padding: 8px 12px;
  background: #FFFFFF;
  border-radius: 4px;
  border-left: 3px solid #1677FF;
}

.info-item strong {
  color: #000000;
  margin-right: 8px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .route-test {
    padding: 16px;
  }
  
  .route-item {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .route-link,
  .route-button {
    min-width: auto;
    text-align: center;
  }
  
  .route-desc {
    text-align: center;
    font-size: 13px;
  }
}
</style>
